package elijah.base.utils;

import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

public class CommonUtils {
    public static final String EMPTY = "";


    public static void postToMainThread(Action result) {
        Disposable subscribe = Completable.complete()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(result, Throwable::printStackTrace);
    }

    public static void postStringToMainThread(String msg, Consumer<String> result) {
        Disposable subscribe = Observable.just(msg)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(result, Throwable::printStackTrace);
    }


}
